//
//  MySelfVC.m
//  YaoHeAPP
//
//  Created by mac on 15/11/20.
//  Copyright (c) 2015年 mac. All rights reserved.
//

//*************************我的个人界面

#import "MySelfVC.h"
#import "Controller.h"
#import "Define.h"
#import "Masonry.h"
#import "UIImageView+WebCache.h"
#import "UMMobClick/MobClick.h"
#import "MesageTableViewController.h"
#import "messageViewController.h"
#import "SetViewController.h"
#import "WebVC.h"
#import <ShareSDK/ShareSDK.h>
#import <ShareSDKUI/ShareSDK+SSUI.h>
#import "InformationShareView.h"
#import "InformationSet.h"
#import "BlackNameVC.h"
#import "ShowMessageView.h"
#import "QualityInspectionVC.h"
#import "OrderVC.h"
#import "CompanyVC.h"
#import "CreateCompanyVC.h"
#import "CMMesgViewController.h"
#import "MyorderVC.h"
#import "zijinzhanghuVC.h"
#import "zhanghumingxiVC.h"
#import "daizhifuVC.h"
#import "huankuanVC.h"
#import "IntegralViewController.h"
#import "NSString+formatWithFloat.h"
#import "TongJiBaoBiaoViewController.h"
#import "YongHuQuanXuanModel.h"
#import "MJExtension.h"
#import "FindCompanyViewController.h"
#import "CompanyInviteCodeViewController.h"
#import "TongYong.h"
#define kDefineTagCardinalNumber 300

@interface MySelfVC () <UITableViewDataSource, UITableViewDelegate, InformationShareViewDelegate,UIAlertViewDelegate> {
    NSInteger width;
    NSInteger height;
    UITableView *_tableview;
    NSArray *cellImage;
    NSArray *cellName;
    
    //头像
    UIImageView*headImage;
    //显示名字
    UILabel *Namelable;
    //分数
    UILabel *NUMlable;
    //显示手机号
    UILabel*phoneLabel;
    //认证图片
    UIImageView *renzheng;
    UIView     *_shareMaskView;
    NSString *renzhengstate;
    NSString *comid;
    NSMutableArray *numberarray;
    UIView *guanliView;
    UIView *_orderView;
    NSString *iphoneNum;
    UIScrollView *_backGroundscrollView;                                // 背景scrollView
    
}
@property (nonatomic, strong)InformationShareView *shareView;
@property (nonatomic, strong)YongHuQuanXuanModel *yongHuQuanXuanModel;
@end

@implementation MySelfVC

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [MobClick endLogPageView:@"MySelfVC"];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [MobClick beginLogPageView:@"MySelfVC"];
    
    [self panduanCreate];
    //请求数据
    [self uplaData];
}

-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden=YES;
    width=self.view.frame.size.width;
    height=self.view.frame.size.height;
    
    self.view.backgroundColor=[UIColor colorWithRed:230/255.0 green:232/255.0 blue:241/255.0  alpha:1];
    
    cellImage = @[@"ic_tongjibaobiao",@"ic_personal_testing",@"ic_personal_share",@"qiandao",@"ic_personal_help",@"yijianfankui",@"ic_personal_call"];
    cellName = @[@"统计报表",@"申请质检",@"推荐好友",@"签到送积分",@"帮助中心",@"意见反馈",@"呼叫客服"];
    
    UIView * navcBar =[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 191)];
    UIImage*img =[UIImage imageNamed:@"meViewback"];
    navcBar.layer.contents=(id)img.CGImage;
    [self.view addSubview:navcBar];
    
    // 导航条标题
    UILabel*titleLabel=[[UILabel alloc]init];
    titleLabel.text=@"我的";
    titleLabel.font=Font(17);
    titleLabel.textAlignment=NSTextAlignmentCenter;
    titleLabel.font=[UIFont systemFontOfSize:15];
    titleLabel.textColor=[UIColor whiteColor];
    [navcBar addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(33);
            make.left.offset(width/2-50);
            make.width.offset(100);
            make.height.offset(20);
    }];

    //设置按钮
    UIButton*leftButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [leftButton setBackgroundImage:[UIImage imageNamed:@"ic_personal_setting"] forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(setBtn) forControlEvents:UIControlEventTouchUpInside];
    [navcBar addSubview:leftButton];
    [leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(33);
        make.width.offset(21);
        make.height.offset(21);
        make.left.offset(15);
    }];
    
    //右侧信息按钮
    UIButton*rightButton=[UIButton buttonWithType:UIButtonTypeCustom];
    [rightButton setBackgroundImage:[UIImage imageNamed:@"ic_personal_notification"] forState:UIControlStateNormal];
    [rightButton addTarget:self action:@selector(messageBtn) forControlEvents:UIControlEventTouchUpInside];
    [navcBar addSubview:rightButton];
    [rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(33);
        make.right.offset(-15);
        make.width.offset(21);
        make.height.offset(21);
    }];

    // 头像
    headImage=[[UIImageView alloc]init];
    headImage.frame=CGRectMake(25, 75, 60, 60);
    headImage.layer.masksToBounds=YES;
    headImage.layer.cornerRadius=30;
    [navcBar addSubview:headImage];
    
    // 显示名字
    Namelable=[[UILabel alloc]init];
    Namelable.textColor=[UIColor whiteColor];
    Namelable.font=[UIFont systemFontOfSize:13];
    [navcBar addSubview:Namelable];
    [Namelable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(headImage.mas_right).offset(14) ;
        make.height.offset(22);
        make.width.offset(200);
        make.top.offset(85);
    }];
    
    //显示手机号
    phoneLabel=[[UILabel alloc]init];
    phoneLabel.textColor=[UIColor whiteColor];
    phoneLabel.textAlignment=NSTextAlignmentLeft;
    phoneLabel.font=[UIFont systemFontOfSize:13];
    [navcBar addSubview:phoneLabel];
    [phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(headImage.mas_right).offset(14) ;
        make.top.offset(108);
        make.width.offset(120);
        make.height.offset(22);
    }];
    
    //箭头图片
    UIImageView*image=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"returnback"]];
    [navcBar addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(95);
        make.right.offset(-15);
        make.width.offset(20);
        make.height.offset(20);
    }];

    //大的按钮点击进入个人信息设置界面
    UIButton *myBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    myBtn.frame=CGRectMake(0, 75, self.view.frame.size.width, 70);
    myBtn.backgroundColor=[UIColor clearColor];
    [myBtn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [navcBar addSubview:myBtn];
    
    //管理项目
    NSArray *name=@[@"账户余额",@"积分",@"优惠券"];
    numberarray=[[NSMutableArray alloc]init];
    guanliView=[[UIView alloc]initWithFrame:CGRectMake(0, 147, self.view.frame.size.width, 44)];
    guanliView.backgroundColor=[UIColor colorWithRed:33/255.0 green:136/255.0 blue:174/255.0  alpha:1];
    [navcBar addSubview:guanliView];
    
    //定义分割线
    for (NSInteger i=0; i<2; i++) {
        UIImageView *line=[[UIImageView alloc]init];
        line.backgroundColor=[UIColor whiteColor];
        NSInteger kuan=(self.view.frame.size.width-1)/3;
        line.frame=CGRectMake(kuan+(kuan+0.5)*i, 5, 0.5, 34);
        [guanliView addSubview:line];
    }
    
    for (NSInteger i=0; i<3; i++) {
        //定义名称
        NSInteger kuan=(self.view.frame.size.width-1)/3;
        UILabel *namela=[[UILabel alloc]init];
        namela.text=name[i];
        namela.font=[UIFont systemFontOfSize:12];
        namela.textColor=[UIColor whiteColor];
        namela.frame=CGRectMake((kuan+0.5)*i, 21, kuan, 20);
        namela.textAlignment=NSTextAlignmentCenter;
        [guanliView addSubview:namela];
        
        //定义数字
        UILabel *numberlabel=[[UILabel alloc]init];
        numberlabel.tag=500+i;
        numberlabel.font=[UIFont systemFontOfSize:12];
        numberlabel.textColor=[UIColor whiteColor];
        numberlabel.frame=CGRectMake((kuan+0.5)*i, 4, kuan, 20);
        numberlabel.textAlignment=NSTextAlignmentCenter;
        [guanliView addSubview:numberlabel];
        
        //定义按钮
        UIButton*guanliButton=[UIButton buttonWithType:UIButtonTypeCustom];
        guanliButton.backgroundColor=[UIColor clearColor];
        guanliButton.frame=CGRectMake(kuan*i, 0, kuan, 44);
        guanliButton.tag=10+i;
        [guanliButton addTarget:self action:@selector(guanliButtonBtn:) forControlEvents:UIControlEventTouchUpInside];
        [guanliView addSubview:guanliButton];
    }
    
    // 在底部添加scrollView 实现滑动效果
    _backGroundscrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 191, width, height-191)];
    _backGroundscrollView.scrollEnabled = YES;
    [self.view addSubview:_backGroundscrollView];

    //我的订单view
    UIView *orderView=[[UIView alloc]initWithFrame:CGRectMake(0, 0 , self.view.frame.size.width, 101)];
    orderView.backgroundColor=[UIColor whiteColor];
    [_backGroundscrollView addSubview:orderView];
    _orderView = orderView;
    
    UIImageView *orderImageV=[[UIImageView alloc]initWithFrame:CGRectMake(15, 10, 20, 23)];
    orderImageV.image=[UIImage imageNamed:@"order"];
    [orderView addSubview:orderImageV];
    
    UILabel *orderla=[[UILabel alloc]initWithFrame:CGRectMake(45, 10, 120, 25)];
    orderla.text=@"我的订单";
    orderla.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0  alpha:1];
    orderla.font=[UIFont systemFontOfSize:13];
    [orderView addSubview:orderla];

    UILabel *chakan=[[UILabel alloc]initWithFrame:CGRectMake(width-15-20-120, 10, 120, 25)];
    chakan.text=@"查看全部订单";
    chakan.textAlignment=NSTextAlignmentRight;
    chakan.textColor=[UIColor grayColor];
    chakan.font=[UIFont systemFontOfSize:11];
    [orderView addSubview:chakan];

    UIImageView *jiantouImageV=[[UIImageView alloc]initWithFrame:CGRectMake(width-15-10, 15, 10, 15)];
    jiantouImageV.image=[UIImage imageNamed:@"ic_arraw"];
    [orderView addSubview:jiantouImageV];

    //大的按钮点击进订单界面
    UIButton *orderBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    orderBtn.frame=CGRectMake(0, 0, self.view.frame.size.width, 44);
    orderBtn.backgroundColor=[UIColor clearColor];
    [orderBtn addTarget:self action:@selector(orderBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [orderView addSubview:orderBtn];

    UIImageView *line=[[UIImageView alloc]initWithFrame:CGRectMake(0, 44, self.view.frame.size.width, 0.5)];
    line.backgroundColor=[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0  alpha:1];
    [orderView addSubview:line];
    
    //订单view
    NSArray *ordername=@[@"待付款",@"待提货",@"申请加工",@"待还款"];
    NSArray *orderImage=@[@"daifukuanimg",@"daitihuoimg",@"jiagongimg",@"daihuankuanimg"];
    
    for (NSInteger i=0; i<4; i++) {
        NSInteger kuan=(self.view.frame.size.width-1)/4;
        //定义项目图片
        NSInteger jianju=(kuan-21)/2;
        UIImageView *naimage=[[UIImageView alloc]init];
        naimage.frame=CGRectMake(kuan*i+jianju, 52, 21, 21);
        naimage.image=[UIImage imageNamed:orderImage[i] ];
        [orderView addSubview:naimage];
        
        if (0 == i || 3 == i) {
            UILabel *yuanquanLabel = [[UILabel alloc] init];
            yuanquanLabel.frame = CGRectMake(naimage.right+6, naimage.top, 16, 16);
            yuanquanLabel.layer.masksToBounds = YES;
            yuanquanLabel.textAlignment = NSTextAlignmentCenter;
            yuanquanLabel.textColor = [UIColor whiteColor];
            yuanquanLabel.font = Font(10);
            yuanquanLabel.tag = kDefineTagCardinalNumber + i;
            yuanquanLabel.layer.cornerRadius = 8;
            yuanquanLabel.backgroundColor = RGBCOLOR(246, 90, 52);
            yuanquanLabel.hidden = YES;
            [orderView addSubview:yuanquanLabel];
        }
        
        //定义名称
        UILabel *namela=[[UILabel alloc]init];
        namela.text=ordername[i];
        namela.font=[UIFont systemFontOfSize:12];
        namela.textColor=[UIColor grayColor];
        namela.frame=CGRectMake(kuan*i, 75, kuan, 22);
        namela.textAlignment=NSTextAlignmentCenter;
        [orderView addSubview:namela];
        
        //定义按钮
        UIButton*ViewButton=[UIButton buttonWithType:UIButtonTypeCustom];
        ViewButton.backgroundColor=[UIColor clearColor];
        ViewButton.frame=CGRectMake(kuan*i, 44, kuan, 57);
        ViewButton.tag=10+i;
        [ViewButton addTarget:self action:@selector(orderViewBtn:) forControlEvents:UIControlEventTouchUpInside];
        [orderView addSubview:ViewButton];
    }
    
    //管理项目
    NSArray *guanliname=@[@"公司管理",@"资金账户",@"提货单",@"加工单"];
    NSArray *guanliImage=@[@"gongsiguanliimg",@"zijinzhanghuimg",@"tihuodanimg",@"jiagongdanimg"];
    
    UIView *towView=[[UIView alloc]initWithFrame:CGRectMake(0, 106, self.view.frame.size.width, 60)];
    towView.backgroundColor=[UIColor whiteColor];
    [_backGroundscrollView addSubview:towView];
    
    NSInteger kuan1=(self.view.frame.size.width-1.5)/4;
    //认证图片
    renzheng=[[UIImageView alloc]initWithFrame:CGRectMake(kuan1-27, 0, 25, 25)];
    [towView addSubview:renzheng];
    
    
     //定义分割线
    for (NSInteger i=0; i<3; i++) {
        UIImageView *line=[[UIImageView alloc]init];
        line.backgroundColor=[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0  alpha:1];
        NSInteger kuan=(self.view.frame.size.width-1.5)/4;
        line.frame=CGRectMake(kuan+(kuan+0.5)*i, 10, 0.5, 40);
        [towView addSubview:line];
    }
    
    for (NSInteger i=0; i<4; i++) {
        //定义名称
        NSInteger kuan=(self.view.frame.size.width-1.5)/4;
        UILabel *namela=[[UILabel alloc]init];
        namela.text=guanliname[i];
        namela.font=[UIFont systemFontOfSize:12];
        namela.textColor=[UIColor grayColor];
        namela.frame=CGRectMake((kuan+0.5)*i, 40, kuan, 22);
        namela.textAlignment=NSTextAlignmentCenter;
        [towView addSubview:namela];

        //定义项目图片
        NSInteger jianju=(kuan-34)/2;
        UIImageView *naimage=[[UIImageView alloc]init];
         naimage.frame=CGRectMake((kuan+0.5)*i+jianju, 5, 34, 34);
        naimage.image=[UIImage imageNamed:guanliImage[i]];
        [towView addSubview:naimage];
        
        //定义按钮
        UIButton*ViewButton=[UIButton buttonWithType:UIButtonTypeCustom];
        ViewButton.backgroundColor=[UIColor clearColor];
        ViewButton.frame=CGRectMake((kuan+0.5)*i, 0, kuan, 60);
        ViewButton.tag=1000+i;
        [ViewButton addTarget:self action:@selector(ViewBtn:) forControlEvents:UIControlEventTouchUpInside];
        [towView addSubview:ViewButton];
    }
   
    //定义下部列表
    _tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, towView.bottom+5, self.view.frame.size.width, height-190) style:UITableViewStylePlain];
    _tableview.dataSource=self;
    _tableview.delegate=self;
    _tableview.backgroundColor=[UIColor colorWithRed:230/255.0 green:232/255.0 blue:241/255.0  alpha:1];
    _tableview.scrollEnabled = NO;
    _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_backGroundscrollView addSubview:_tableview];
    _backGroundscrollView.contentSize = CGSizeMake(width, 212+(cellImage.count*50));
}

//我的积分按钮
-(void)guanliButtonBtn:(UIButton *)but
{
    NSInteger tg=but.tag;
    if (tg==10){
        //先判断是否开资金账户
        [self  isfoundkaitong];
    }else if(tg==11){
        IntegralViewController *integralViewController = [[IntegralViewController alloc] init];
        [self.navigationController pushViewController:integralViewController animated:YES];
    }else if(tg==12){
        
    }
}

//我的订单按钮
- (void)orderBtnAction {
    
    NSString *IDnumString=[NSString stringWithFormat:@"%@",_yongHuQuanXuanModel.COMPANY_ID];
    if ([IDnumString isEqualToString:@"0"]) {
        NSString *statusSt=[NSString stringWithFormat:@"%@",_yongHuQuanXuanModel.STATUS];
        if ([TongYong isBlankObjectAndStr:_yongHuQuanXuanModel.STATUS]||[statusSt isEqualToString:@"-1"])  {
            //没有值便是 申请
            //没有绑定公司 （提示是否加入公司  或者  创建公司  或者 输入验证码 加入公司）
            
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                            message:@"您还没有“创建/加入”一家公司，不能进行该操作"
                                                           delegate:self
                                                  cancelButtonTitle:@"取消"
                                                  otherButtonTitles:@"创建公司",@"查找公司",@"输入邀请码",nil];
            
            //这个属性继承自UIView，当一个视图中有多个AlertView时，可以用这个属性来区分
            alert.tag = 0;
            //只读属性，看AlertView是否可见
            [alert show];
            
        }else{
            //0申请中  -1被拒绝
            NSString *messageSt=[NSString stringWithFormat:@"您于%@申请加入“%@”，公司主管理员尚未同意您加入公司。",_yongHuQuanXuanModel.APPLY_TIME,_yongHuQuanXuanModel.APPLY_COMPANY_NAME];
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                            message:messageSt
                                                           delegate:self
                                                  cancelButtonTitle:@"取消申请"
                                                  otherButtonTitles:@"关闭",nil];
            
            //这个属性继承自UIView，当一个视图中有多个AlertView时，可以用这个属性来区分
            alert.tag = 100;
            //只读属性，看AlertView是否可见
            [alert show];
            
        }
        
    }else{
        // 进入
        
        [MobClick event:@"mineOrders"];
        MyorderVC*order=[[MyorderVC alloc]init];
        [self.navigationController pushViewController:order animated:YES];
        
    }
    

}

//我的订单下面的按钮
-(void)orderViewBtn:(UIButton *)but
{
        NSString *IDnumString=[NSString stringWithFormat:@"%@",_yongHuQuanXuanModel.COMPANY_ID];
        if ([IDnumString isEqualToString:@"0"]) {
            NSString *statusSt=[NSString stringWithFormat:@"%@",_yongHuQuanXuanModel.STATUS];
            if ([TongYong isBlankObjectAndStr:_yongHuQuanXuanModel.STATUS]||[statusSt isEqualToString:@"-1"])  {
                //没有值便是 申请
                //没有绑定公司 （提示是否加入公司  或者  创建公司  或者 输入验证码 加入公司）
                
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                message:@"您还没有“创建/加入”一家公司，不能进行该操作"
                                                               delegate:self
                                                      cancelButtonTitle:@"取消"
                                                      otherButtonTitles:@"创建公司",@"查找公司",@"输入邀请码",nil];
                
                //这个属性继承自UIView，当一个视图中有多个AlertView时，可以用这个属性来区分
                alert.tag = 0;
                //只读属性，看AlertView是否可见
                [alert show];
                
            }else{
                //0申请中  -1被拒绝
                NSString *messageSt=[NSString stringWithFormat:@"您于%@申请加入“%@”，公司主管理员尚未同意您加入公司。",_yongHuQuanXuanModel.APPLY_TIME,_yongHuQuanXuanModel.APPLY_COMPANY_NAME];
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                message:messageSt
                                                               delegate:self
                                                      cancelButtonTitle:@"取消申请"
                                                      otherButtonTitles:@"关闭",nil];
                
                //这个属性继承自UIView，当一个视图中有多个AlertView时，可以用这个属性来区分
                alert.tag = 100;
                //只读属性，看AlertView是否可见
                [alert show];
                
            }
            
        }else{
            //创建公司 进入
            
            NSInteger tg=but.tag;
            if (tg==10){
                [MobClick event:@"pendingPayment"];
                daizhifuVC *daiorder=[[daizhifuVC alloc]init];
                [self.navigationController pushViewController:daiorder animated:YES];
                
            }else if(tg==11){
                
                [MobClick event:@"pendingDelivery"];
                [ShowMessageView    showMessage:@"敬请期待"];
                
            }else if(tg==12){
                
                [MobClick event:@"applicationProcessing"];
                [ShowMessageView    showMessage:@"敬请期待"];
                
            }else if(tg==13){
                
                [MobClick event:@"pendingRepayment"];
                huankuanVC *hkvc=[[huankuanVC alloc]init];
                [self.navigationController pushViewController:hkvc animated:YES];
            }
            
        }
    
    
}

-(void)ViewBtn:(UIButton *)button
{
    NSInteger tg=button.tag;
    if (tg==1000) {
        [MobClick event:@"companyManagement"];
        /*
         先判断是否有公司
         如果没公司  就不给进
         然后判断登录的帐号是否是主账号
         如果不是主账号
         就直接进公司详情页
         如果是主账号  就进公司管理
         */

        //判断是否有公司
        [self ishaveCompany];
        
    }else if (tg==1001) {
        [MobClick event:@"fundingAccount"];
        
        //先判断是否开资金账户
        [self  isfoundkaitong];
        
    }else if (tg==1002) {
        [MobClick event:@"billOfLading"];
        [ShowMessageView    showMessage:@"敬请期待"];
        
    }else if (tg==1003) {
        [MobClick event:@"workOrder"];
        [ShowMessageView    showMessage:@"敬请期待"];
        
    }
    
}

-(void)isfoundkaitong
{

    //先判断是否开通资金账户
    [Controller requestWithURL:ISFOUND jsondic:nil finishBlock:^(ClassData* data) {
        
        if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]])
        {
            //            "is_bind" = 1;
            //            "is_found" = 1;
            //            "is_main" = 1;
            //            "main_mobile" = 0;
            //            "main_name" = "";
            
            
            //            "main_mobile":0,               只有当前账号绑定公司 并且不是主账号的时候 此字段才有手机号  默认为0
            //            "is_bind":1,                       1已绑定   0未绑定
            //            "is_main":0,                      1主账号   0子账号
            //            "main_name":"",
            //            "is_found":1                     1已开通   0未开通
            
            //是否开通
            NSString *is_found=[NSString  stringWithFormat:@"%@",data.data[@"is_found"]];
            NSInteger is_fd=is_found.integerValue;
            
            //是否是 主账号，子账号
            NSString *is_main=[NSString  stringWithFormat:@"%@",data.data[@"is_main"]];
            NSInteger is_ma=is_main.integerValue;
            //是否绑定
            NSString *is_bind=[NSString  stringWithFormat:@"%@",data.data[@"is_bind"]];
            NSInteger is_b=is_bind.integerValue;
            
            
            iphoneNum=data.data[@"main_mobile"];
            NSString *main_name;
            if ([TongYong isBlankObjectAndStr:data.data[@"main_name"]]) {
                main_name=@"";
            }else{
                main_name=[NSString stringWithFormat:@"%@",data.data[@"main_name"]];
            }
            
            if (is_fd==1) {
                //已开通  资金账户（可以查看资金明细）
                
                zhanghumingxiVC*zijinVC=[[zhanghumingxiVC alloc]init];
                [self.navigationController pushViewController:zijinVC animated:YES];
                
            }else{
                //未开通
                //先判断是否开通     没开通的时候 判断是否有公司   然后再判断主子账号
                
                if (is_b==1) {
                    //绑定了公司  提示其开通资金账户
                    if (is_ma==1) {
                        //主账号
                        //初始化AlertView
                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                        message:@"贵公司还没有开通资金账户！"
                                                                       delegate:self
                                                              cancelButtonTitle:@"开通资金账户"
                                                              otherButtonTitles:nil,nil];
                        alert.tag = 40;
                        [alert show];
                        
                    }else{
                        //子账号
                        //初始化AlertView
                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                        message:[NSString stringWithFormat:@"贵公司还没有开通资金账户！\n请联系主账号，登录信用行网站或吆喝APP开通资金账户。\n主账号：%@ %@",main_name,iphoneNum]
                                                                       delegate:self
                                                              cancelButtonTitle:@"取消"
                                                              otherButtonTitles:@"呼叫客服",@"呼叫主账号",nil];
                        alert.tag = 41;
                        [alert show];
                        
                    }
                    
                }else{
                    NSString *statusSt=[NSString stringWithFormat:@"%@",_yongHuQuanXuanModel.STATUS];
                    if ([TongYong isBlankObjectAndStr:_yongHuQuanXuanModel.STATUS]||[statusSt isEqualToString:@"-1"])  {
                        //没有值便是 申请
                        //没有绑定公司 （提示是否加入公司  或者  创建公司  或者 输入验证码 加入公司）
                        
                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                        message:@"您还没有“创建/加入”一家公司，不能进行该操作"
                                                                       delegate:self
                                                              cancelButtonTitle:@"取消"
                                                              otherButtonTitles:@"创建公司",@"查找公司",@"输入邀请码",nil];
                        
                        //这个属性继承自UIView，当一个视图中有多个AlertView时，可以用这个属性来区分
                        alert.tag = 0;
                        //只读属性，看AlertView是否可见
                         [alert show];
                        
                    }else{
                        //0申请中  -1被拒绝
                        NSString *messageSt=[NSString stringWithFormat:@"您于%@申请加入“%@”，公司主管理员尚未同意您加入公司。",_yongHuQuanXuanModel.APPLY_TIME,_yongHuQuanXuanModel.APPLY_COMPANY_NAME];
                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                        message:messageSt
                                                                       delegate:self
                                                              cancelButtonTitle:@"取消申请"
                                                              otherButtonTitles:@"关闭",nil];
                        
                        //这个属性继承自UIView，当一个视图中有多个AlertView时，可以用这个属性来区分
                        alert.tag = 100;
                        //只读属性，看AlertView是否可见
                        [alert show];
                        
                    }
                    
                }
                
            }
            
        }else
        {
            ALERTSHOW(data.message);
            
            
        }
    }];


}

//判断是否有公司
-(void)ishaveCompany
{
    [Controller requestWithURL:POSTCHECK jsondic:nil finishBlock:^(ClassData *data) {
        
        if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]]){
            YongHuQuanXuanModel *yongHuQuanXuanModel=[YongHuQuanXuanModel mj_objectWithKeyValues:data.data];
            NSString *IDnumString=[NSString stringWithFormat:@"%@",yongHuQuanXuanModel.COMPANY_ID];
            if ([IDnumString isEqualToString:@"0"]) {
                NSString *statusSt=[NSString stringWithFormat:@"%@",yongHuQuanXuanModel.STATUS];
                if ([TongYong isBlankObjectAndStr:yongHuQuanXuanModel.STATUS]||[statusSt isEqualToString:@"-1"])  {
                    //没有值便是 申请
                    //没有绑定公司 （提示是否加入公司  或者  创建公司  或者 输入验证码 加入公司）
                    
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                    message:@"您还没有“创建/加入”一家公司，不能进行该操作"
                                                                   delegate:self
                                                          cancelButtonTitle:@"取消"
                                                          otherButtonTitles:@"创建公司",@"查找公司",@"输入邀请码",nil];
                    
                    //这个属性继承自UIView，当一个视图中有多个AlertView时，可以用这个属性来区分
                    alert.tag = 0;
                    //只读属性，看AlertView是否可见
                    [alert show];
                    
                }else{
                    //0申请中  -1被拒绝
                    NSString *messageSt=[NSString stringWithFormat:@"您于%@申请加入“%@”，公司主管理员尚未同意您加入公司。",yongHuQuanXuanModel.APPLY_TIME,yongHuQuanXuanModel.APPLY_COMPANY_NAME];
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                    message:messageSt
                                                                   delegate:self
                                                          cancelButtonTitle:@"取消申请"
                                                          otherButtonTitles:@"关闭",nil];
                    
                    //这个属性继承自UIView，当一个视图中有多个AlertView时，可以用这个属性来区分
                    alert.tag = 100;
                    //只读属性，看AlertView是否可见
                    [alert show];
                    
                }

            }else{
                
                //如果已经有了公司  判断是否事主账号 10主  0不是主
                NSString *isregtype=[NSString  stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:ISREGTYPE]] ;
                if ([isregtype isEqualToString:@"10"]) {
                    //是主账号 进入公司管理
                    CompanyVC*compvc=[[CompanyVC alloc]init];
                    compvc.RZstate=renzhengstate;
                    compvc.COMid=comid;
                    [self.navigationController pushViewController:compvc animated:YES];
                }else {
                    //不是主账号，进入公司详情
                    
                    CMMesgViewController*CMMesgtVC=[CMMesgViewController new];
                    CMMesgtVC.RZstate=renzhengstate;
                    [self.navigationController pushViewController:CMMesgtVC animated:YES];
                    
                }
                
            }
            
        }else{
            
            ALERTSHOW(data.message);
            
        }
        
    }];

    
}
//判断是否创建公司
-(void)panduanCreate
{
    [Controller requestWithURL:POSTCHECK jsondic:nil finishBlock:^(ClassData *data) {
        if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]]){
            _yongHuQuanXuanModel=[YongHuQuanXuanModel mj_objectWithKeyValues:data.data];
        
        }
    }];
    

}

//根据被点击按钮的索引处理点击事件
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag==0) {
        if(buttonIndex==0){
            //取消
            
        }else if (buttonIndex==1) {
            //创建公司
            CreateCompanyVC*creatVC=[CreateCompanyVC new];
            [self.navigationController pushViewController:creatVC animated:YES];
            
        }else if(buttonIndex==2){
            //查找公司
            FindCompanyViewController*findCompanyViewController=[FindCompanyViewController new];
            [self.navigationController pushViewController:findCompanyViewController animated:NO];
            
        }else if (buttonIndex==3){
            //输入邀请码
            CompanyInviteCodeViewController *companyInviteCodeViewController=[CompanyInviteCodeViewController new];
            [self.navigationController pushViewController:companyInviteCodeViewController animated:YES];
        }
        
    } else if (alertView.tag==40) {
        if (buttonIndex==0) {
            //开通资金账户
        zijinzhanghuVC*zijinVC=[[zijinzhanghuVC alloc]init];
        [self.navigationController pushViewController:zijinVC animated:YES];
            
        }
        
    }else if(alertView.tag==41){
        
        if (buttonIndex==1) {
            //呼叫客服
            //进入打电话页面
            UIWebView *webview = [[UIWebView alloc] init];
            [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel:4008850054"]]];
            [self.view addSubview:webview];
            
        }else if(buttonIndex==2){
            //呼叫主账号
            //进入打电话页面
            UIWebView *webview = [[UIWebView alloc] init];
            NSString *str=[NSString stringWithFormat:@"tel:%@",iphoneNum];
            [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
            [self.view addSubview:webview];

        }if (buttonIndex==0) {
            //取消
        }
    }else if(alertView.tag==100){
        if (buttonIndex==0) {
            //取消申请
            [self quxiaoshenqingBut];
        }else{
        
        }
    
    }
}
//取消加入公司申请
-(void)quxiaoshenqingBut{

    [Controller requestWithURL:PostCancelApply jsondic:nil finishBlock:^(ClassData *data) {
        if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]]){
            ALERTSHOW(@"你已成功取消加入该公司的申请")
        }else{
        
            ALERTSHOW(data.message);
        }
    }];

    
    
}

#pragma  mark--------------分享功能代码-----------------

-(void)sharefriend
{
    [[self rdv_tabBarController] setTabBarHidden:YES animated:YES];
    
    UIWindow * window = [UIApplication sharedApplication].keyWindow ;
    _shareMaskView = [[UIView alloc]init];
    _shareMaskView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
    _shareMaskView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
    
    UIView *actionView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-200)];
    actionView.backgroundColor = [UIColor clearColor];
    UITapGestureRecognizer *tapView = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didClickMaskView)];
    [actionView addGestureRecognizer:tapView];
    [_shareMaskView addSubview:actionView];
    
    _shareView = [[InformationShareView alloc]initWithFrame:CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 200)];
    
    _shareView.delegate = self;
    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.25f];
    _shareView.frame = CGRectMake(0, self.view.frame.size.height - 200, self.view.frame.size.width, 200);
    
    [UIView commitAnimations];
    [_shareMaskView addSubview:_shareView];
    [window addSubview:_shareMaskView];
    
    
}
-(void)didClickCancleButtonInBottomView
{
    [self didClickMaskView];

}
- (void)didClickMaskView
{
    [[self rdv_tabBarController] setTabBarHidden:NO animated:YES];
    
    [UIView animateWithDuration:0.25f animations:^{
        
        _shareView.frame = CGRectMake(0, self.view.frame.size.height, self.view.frame.size.width, 200);
        
    } completion:^(BOOL finished) {
        
        [_shareMaskView removeFromSuperview];
        [_shareView removeFromSuperview];
    }];
}
//代理方法
- (void)shareAppWithTag:(NSInteger)tag{

    if (tag==6000) {
        //微信分享
        [self wechat];
        
    }else if(tag==6001){
        //朋友圈分享
        [self fridenchat];
    }else if (tag==6002){
        //QQ好友
        [self qqfriden];
    }else if (tag==6003){
        //空间
        [self qqhome];
    }
    
}
//微信分享
-(void)wechat
{
    
        //创建分享参数
        NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
        NSString *urlapp=[NSString stringWithFormat:@"%@/web/mobile/app_intro.aspx",BESTHOST];
        [shareParams SSDKSetupShareParamsByText:@"“吆喝”选货助手上线啦！买卖方便，全程免费！小伙伴们还在等什么？快来和我一起“吆喝”吧"
                                         images:@[[UIImage imageNamed:@"144"]]
                                            url:[NSURL URLWithString:urlapp]
                                          title:@"吆喝"
                                           type:SSDKContentTypeAuto];
    
        //进行分享
        [ShareSDK share:SSDKPlatformTypeWechat
             parameters:shareParams
         onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
    
             switch (state) {
                 case SSDKResponseStateSuccess:
                 {
                     [Controller requestWithURL:SHAREPOINT jsondic:nil finishBlock:^(ClassData* data) {
                         if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]])
                         {
                             NSInteger num=[data.data[@"USER_SCORE_INC_NUM"] integerValue];
                             if (num>0) {
                                 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                     message:data.data[@"USER_SCORE_INC_MSG"]
                                                                                    delegate:nil
                                                                           cancelButtonTitle:@"确定"
                                                                           otherButtonTitles:nil];
                                 [alertView show];

                             }else{
                                 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                     message:nil
                                                                                    delegate:nil
                                                                           cancelButtonTitle:@"确定"
                                                                           otherButtonTitles:nil];
                                 [alertView show];

                             
                             }
                             
                             //请求数据
                             [self uplaData];

                         }
                         else
                         {
                             
                         }
                     }];
                     
                     
                                         break;
                 }
                 case SSDKResponseStateFail:
                 {
                     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享失败"
                                                                         message:[NSString stringWithFormat:@"%@", error]
                                                                        delegate:nil
                                                               cancelButtonTitle:@"确定"
                                                               otherButtonTitles:nil];
                     [alertView show];
                     break;
                 }
                 case SSDKResponseStateCancel:
                 {
                     UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享已取消"
                                                                         message:nil
                                                                        delegate:nil
                                                               cancelButtonTitle:@"确定"
                                                               otherButtonTitles:nil];
                     [alertView show];
                     break;
                 }
                 default:
                     break;
             }
    
         }];
    
}
//微信朋友圈分享
-(void)fridenchat
{
    //创建分享参数
    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
    NSString *urlapp=[NSString stringWithFormat:@"%@/web/mobile/app_intro.aspx",BESTHOST];
    [shareParams SSDKSetupShareParamsByText:@"“吆喝”选货助手上线啦！买卖方便，全程免费！小伙伴们还在等什么？快来和我一起“吆喝”吧"
                                     images:@[[UIImage imageNamed:@"144"]]
                                        url:[NSURL URLWithString:urlapp]
                                      title:@"吆喝"
                                       type:SSDKContentTypeAuto];
    
    //进行分享
    [ShareSDK share:SSDKPlatformSubTypeWechatTimeline
         parameters:shareParams
     onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
         
         switch (state) {
             case SSDKResponseStateSuccess:
             {
                 
                 [Controller requestWithURL:SHAREPOINT jsondic:nil finishBlock:^(ClassData* data) {
                     if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]])
                     {
                         NSInteger num=[data.data[@"USER_SCORE_INC_NUM"] integerValue];
                         if (num>0) {
                             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                 message:data.data[@"USER_SCORE_INC_MSG"]
                                                                                delegate:nil
                                                                       cancelButtonTitle:@"确定"
                                                                       otherButtonTitles:nil];
                             [alertView show];
                             
                         }else{
                             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                 message:nil
                                                                                delegate:nil
                                                                       cancelButtonTitle:@"确定"
                                                                       otherButtonTitles:nil];
                             [alertView show];
                             
                             
                         }
                         
                         //请求数据
                         
                         [self uplaData];

                         
                     }
                     else
                     {
                         
                     }
                 }];
                 break;
             }
             case SSDKResponseStateFail:
             {
                 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享失败"
                                                                     message:[NSString stringWithFormat:@"%@", error]
                                                                    delegate:nil
                                                           cancelButtonTitle:@"确定"
                                                           otherButtonTitles:nil];
                 [alertView show];
                 break;
             }
             case SSDKResponseStateCancel:
             {
                 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享已取消"
                                                                     message:nil
                                                                    delegate:nil
                                                           cancelButtonTitle:@"确定"
                                                           otherButtonTitles:nil];
                 [alertView show];
                 break;
             }
             default:
                 break;
         }
         
     }];

    
    
}
//qq好友分享
-(void)qqfriden
{
    //创建分享参数
    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
    NSString *urlapp=[NSString stringWithFormat:@"%@/web/mobile/app_intro.aspx",BESTHOST];
    [shareParams SSDKSetupShareParamsByText:@"“吆喝”选货助手上线啦！买卖方便，全程免费！小伙伴们还在等什么？快来和我一起“吆喝”吧"
                                     images:@[[UIImage imageNamed:@"144"]]
                                        url:[NSURL URLWithString:urlapp]
                                      title:@"吆喝"
                                       type:SSDKContentTypeAuto];
    
    //进行分享
    [ShareSDK share:SSDKPlatformSubTypeQQFriend
         parameters:shareParams
     onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
         
         switch (state) {
             case SSDKResponseStateSuccess:
             {
                 
                 [Controller requestWithURL:SHAREPOINT jsondic:nil finishBlock:^(ClassData* data) {
                     if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]])
                     {   
                         NSInteger num=[data.data[@"USER_SCORE_INC_NUM"] integerValue];
                         if (num>0) {
                             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                 message:data.data[@"USER_SCORE_INC_MSG"]
                                                                                delegate:nil
                                                                       cancelButtonTitle:@"确定"
                                                                       otherButtonTitles:nil];
                             [alertView show];
                             
                         }else{
                             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                 message:nil
                                                                                delegate:nil
                                                                       cancelButtonTitle:@"确定"
                                                                       otherButtonTitles:nil];
                             [alertView show];
                             
                             
                         }
                         //请求数据
                         
                         [self uplaData];

                         
                     }
                     else
                     {
                         
                     }
                 }];
                 break;
             }
             case SSDKResponseStateFail:
             {
                 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享失败"
                                                                     message:[NSString stringWithFormat:@"%@", error]
                                                                    delegate:nil
                                                           cancelButtonTitle:@"确定"
                                                           otherButtonTitles:nil];
                 [alertView show];
                 break;
             }
             case SSDKResponseStateCancel:
             {
                 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享已取消"
                                                                     message:nil
                                                                    delegate:nil
                                                           cancelButtonTitle:@"确定"
                                                           otherButtonTitles:nil];
                 [alertView show];
                 break;
             }
             default:
                 break;
         }
         
     }];
 
    
}
//qq空间分享
-(void)qqhome
{
    //创建分享参数
    NSMutableDictionary *shareParams = [NSMutableDictionary dictionary];
    NSString *urlapp=[NSString stringWithFormat:@"%@/web/mobile/app_intro.aspx",BESTHOST];
    [shareParams SSDKSetupShareParamsByText:@"“吆喝”选货助手上线啦！买卖方便，全程免费！小伙伴们还在等什么？快来和我一起“吆喝”吧"
                                     images:@[[UIImage imageNamed:@"144"]]
                                        url:[NSURL URLWithString:urlapp]
                                      title:@"吆喝"
                                       type:SSDKContentTypeAuto];
    
    //进行分享
    [ShareSDK share:SSDKPlatformSubTypeQZone
         parameters:shareParams
     onStateChanged:^(SSDKResponseState state, NSDictionary *userData, SSDKContentEntity *contentEntity, NSError *error) {
         
         switch (state) {
             case SSDKResponseStateSuccess:
             {
                 
                 [Controller requestWithURL:SHAREPOINT jsondic:nil finishBlock:^(ClassData* data) {
                     if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]])
                     {
                         NSInteger num=[data.data[@"USER_SCORE_INC_NUM"] integerValue];
                         if (num>0) {
                             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                 message:data.data[@"USER_SCORE_INC_MSG"]
                                                                                delegate:nil
                                                                       cancelButtonTitle:@"确定"
                                                                       otherButtonTitles:nil];
                             [alertView show];
                             
                         }else{
                             UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享成功"
                                                                                 message:nil
                                                                                delegate:nil
                                                                       cancelButtonTitle:@"确定"
                                                                       otherButtonTitles:nil];
                             [alertView show];
                             
                             
                         }
                         //请求数据
                         
                         [self uplaData];

                         
                     }
                     else
                     {
                         
                     }
                 }];
                 break;
             }
             case SSDKResponseStateFail:
             {
                 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享失败"
                                                                     message:[NSString stringWithFormat:@"%@", error]
                                                                    delegate:nil
                                                           cancelButtonTitle:@"确定"
                                                           otherButtonTitles:nil];
                 [alertView show];
                 break;
             }
             case SSDKResponseStateCancel:
             {
                 UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"分享已取消"
                                                                     message:nil
                                                                    delegate:nil
                                                           cancelButtonTitle:@"确定"
                                                           otherButtonTitles:nil];
                 [alertView show];
                 break;
             }
             default:
                 break;
         }
         
     }];
    
}

#pragma  mark--------------请求数据-----------------
-(void)uplaData
{
    
    [Controller requestWithURL:USERCENTER jsondic:nil finishBlock:^(ClassData* data) {
        if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]]) {
            [headImage sd_setImageWithURL:[NSURL URLWithString:data.data[@"LOGO_PATH"]] placeholderImage:[UIImage imageNamed:@"default_head"]];
            
            NSString *namestr=data.data[@"REG_NAME"];
            
            if (namestr.length==0) {
                namestr=@"请填写姓名";
            }
            Namelable.text=namestr;
            //             NUMlable.text=[NSString stringWithFormat:@"%@分",data.data[@"USER_SCORE"]];
            phoneLabel.text=data.data[@"REG_MOBILE"];
            NSString *remobile=[NSString stringWithFormat:@"%@",data.data[@"REG_MOBILE"]];
            [[NSUserDefaults standardUserDefaults] setObject:remobile forKey:kREGMOBILE];

            //
            //            "AVAILABLE_FOUND" = "9976525.25";
            //            "COMPANY_CERTIFICATION" = 10;
            //            "COMPANY_ID" = 1461814838532416;
            //            "COMPANY_NAME" = "008\U4e70\U5bb6\U516c\U53f8";
            //            "COUPON_MOUNT" = 0;
            //            "IS_FOUND" = 1;
            //            "LOGO_PATH" = "http://zh.xinyonghang.com/img/2016/04/28/adhp6un5h.jpg";
            //            "NEED_PAY_MOUNT" = 0;
            //            "REFUND_ORDER_MOUNT" = 1;
            //            "REG_MOBILE" = 13900000008;
            //            "REG_NAME" = "\U5566\U5566\U5566";
            //            "USER_SCORE" = 1425;
            
            [numberarray removeAllObjects];
            
            NSString *jine=[NSString stringWithFormat:@"%@",data.data[@"AVAILABLE_FOUND"]];
            NSDecimalNumber *AVAILABLE_FOUND = [[NSDecimalNumber alloc] initWithString:jine];//单个重量
            NSString *st=[NSString  notRounding:AVAILABLE_FOUND afterPoint:2];
            [numberarray addObject:st];
            
            NSString *jifen=[NSString stringWithFormat:@"%d",[data.data[@"USER_SCORE"] integerValue]];
            [numberarray  addObject:jifen];
            
            NSString *youhuiquan=[NSString stringWithFormat:@"%d",[data.data[@"COUPON_MOUNT"] integerValue]];
            
            [numberarray addObject:youhuiquan];
            
            NSInteger stus=[data.data[@"COMPANY_CERTIFICATION"] integerValue];
            NSInteger paSt=[data.data[@"COMPANY_ID"] integerValue];
            
            if (paSt == 0) {
                
                NSString *statusSt=[NSString stringWithFormat:@"%@",_yongHuQuanXuanModel.STATUS];
                if ([statusSt isEqualToString:@"0"]) {
                    //申请中
                    renzheng.image = [UIImage imageNamed:@"ic_renzhengzhuangtai"];
                    renzhengstate = @"未绑定";
                }else{
                    // 未绑定
                    renzheng.image = [UIImage imageNamed:@"ic_company_state_no_company"];
                    renzhengstate = @"未绑定";
                }
                
                
            } else {
                comid = data.data[@"COMPANY_ID"];
                if (stus == 10) {
                    // 已认证   0未申请认证（以前叫未认证） 1申请认证中  5被拒绝 10 已认证。
                    renzheng.image = [UIImage imageNamed:@"ic_company_state_apply"];
                    renzhengstate = @"已认证";
                } else if (stus == 5) {
                    //未认证
                    renzheng.image = [UIImage imageNamed:@"ic_company_state_none_apply"];
                    renzhengstate = @"未通过";
                } else if (stus == 1){
                    //申请认证中
                    renzheng.image = [UIImage imageNamed:@"ic_company_state_applying"];
                    renzhengstate = @"认证中";
                }else {
                    //未认证
                    renzheng.image = [UIImage imageNamed:@"ic_company_state_no_apply"];
                    renzhengstate = @"未认证";
                
                }
            }
            
            NSInteger pendingPayment = [data.data[@"NEED_PAY_MOUNT"] integerValue];//待付款数量
            NSInteger pendingRepayment = [data.data[@"REFUND_ORDER_MOUNT"] integerValue];//待还款数量
            
            UILabel *tempPendingPaymentLabel = [_orderView viewWithTag:kDefineTagCardinalNumber];
            if (pendingPayment > 99) {
                tempPendingPaymentLabel.text = @"99+";
            } else {
                tempPendingPaymentLabel.text = [NSString stringWithFormat:@"%ld", (long)pendingPayment];
            }
            
            if (pendingPayment > 0) {
                tempPendingPaymentLabel.hidden = NO;
            } else {
                tempPendingPaymentLabel.hidden = YES;
            }
            
            UILabel *tempPendingRepaymentLabel = [_orderView viewWithTag:kDefineTagCardinalNumber+3];
            if (pendingRepayment > 99) {
                tempPendingRepaymentLabel.text = @"99+";
            } else {
                tempPendingRepaymentLabel.text = [NSString stringWithFormat:@"%ld", (long)pendingRepayment];
            }
            
            if (pendingRepayment > 0) {
                tempPendingRepaymentLabel.hidden = NO;
            } else {
                tempPendingRepaymentLabel.hidden = YES;
            }
            
            //刷新积分数据
            [self upguanliView];
        }
    }];
}

- (void)upguanliView {
    for (NSInteger i=0; i<3; i++) {
        UILabel *la=[guanliView viewWithTag:500+i];
        la.text=numberarray[i];
    }
}


#pragma  mark--------------头部按钮进入的方法-----------------
- (void)click {
    //进入个人设置界面
    [MobClick event:@"mineBasicInformation"];
    
    InformationSet*set=[InformationSet new];
    [self.navigationController pushViewController:set animated:YES];
}

- (void)setBtn {
    //进入设置界面
    SetViewController *setv=[[SetViewController alloc]init];
    [self.navigationController pushViewController:setv animated:YES];
}

- (void)messageBtn {
    
     [MobClick event:@"viewMessageList"];
    
    //进入消息界面
    messageViewController *megview=[[messageViewController alloc]init];
    //跳转时隐藏分栏
    [self.navigationController pushViewController:megview animated:YES];
}

#pragma  mark--------------表格代理方法-----------------
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    

    return cellImage.count;
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   
//    //指定cellIdentifier为自定义的cell
//    static NSString *CellIdentifier = @"OrderListCell";
//
//    //自定义cell类有图片
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
    
    
    NSString *identifier = [NSString stringWithFormat:@"TimeLineCell%ld%ld",(long)indexPath.section,(long)indexPath.row];
    
    //自定义cell类有图片
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];

    
    
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
        
        if (indexPath.row==5) {
        
            UIImageView *cellImageV=[[UIImageView alloc]initWithFrame:CGRectMake(15, 12.5, 25, 25)];
            cellImageV.image=[UIImage imageNamed:cellImage[indexPath.row]];
            cellImageV.tag=100+indexPath.row;
            [cell addSubview:cellImageV];
            
            UILabel *namela=[[UILabel alloc]initWithFrame:CGRectMake(45, 12.5, 120, 25)];
            namela.text=cellName[indexPath.row];
            namela.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0  alpha:1];
            namela.font=[UIFont systemFontOfSize:14];
            namela.tag=1000+indexPath.row;
            [cell addSubview:namela];
            
            UILabel *la=[[UILabel alloc]initWithFrame:CGRectMake(120, 12.5, 120, 25)];
            la.text=@"4008850051";
            la.font=[UIFont systemFontOfSize:16];
            la.textColor=[UIColor colorWithRed:73/255.0 green:192/255.0 blue:219/255.0  alpha:1];
            [cell addSubview:la];
            
            
            UIImageView *line=[[UIImageView alloc]initWithFrame:CGRectMake(15, 49, self.view.frame.size.width, 0.5)];
            line.backgroundColor=[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0  alpha:1];
            [cell addSubview:line];
            
            
        }else{
    
        UIImageView *cellImageV=[[UIImageView alloc]initWithFrame:CGRectMake(15, 12.5, 25, 25)];
        cellImageV.image=[UIImage imageNamed:cellImage[indexPath.row]];
        cellImageV.tag=100+indexPath.row;
        [cell addSubview:cellImageV];
        
        UILabel *namela=[[UILabel alloc]initWithFrame:CGRectMake(45, 12.5, 120, 25)];
        namela.text=cellName[indexPath.row];
        namela.textColor=[UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0  alpha:1];
        namela.font=[UIFont systemFontOfSize:14];
        namela.tag=1000+indexPath.row;
        [cell addSubview:namela];
        
        UIImageView *line=[[UIImageView alloc]initWithFrame:CGRectMake(15, 49, self.view.frame.size.width, 0.5)];
        line.backgroundColor=[UIColor colorWithRed:204/255.0 green:204/255.0 blue:204/255.0  alpha:1];
        [cell addSubview:line];
            
         }
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSInteger cellindex=indexPath.row;
    switch (cellindex) {
        case 0:
            //统计报表
            [self tongjibaobiao];
            break;
        case 1:
            //（申请质检）
            
            [MobClick event:@"applicationQuality"];
            
            [ShowMessageView showMessage:@"敬请期待"];
            break;
        case 2:
            //（推荐好友）
            
            [MobClick event:@"recommendFriends"];
            
            [self  sharefriend];
            break;
        case 3:
            //关于我们（签到送积分）
            
            [MobClick event:@"signIn"];
            
            [self aboutwe];
            break;
        case 4:
            //帮助中心
            
            [MobClick event:@"helpCenter"];
            
            [self helpcenter];
            break;
        case 5:
            //意见反馈
            
            [MobClick event:@"feedback"];
            
            [self yijianfankui];
            break;
        case 6:
            //呼叫客户
            
            [MobClick event:@"callCustomerService"];
            
            [self callout];
            break;
        default:
            break;
    }
}

//统计报表
-(void)tongjibaobiao
{
    TongJiBaoBiaoViewController *tongJiBaoBiaoViewController=[[TongJiBaoBiaoViewController alloc]init];
    [self.navigationController pushViewController:tongJiBaoBiaoViewController animated:NO];


}

//帮助中心
- (void)helpcenter {
    WebVC *helpview=[[WebVC alloc]init];
    helpview.titleTxt=@"帮助中心";
     NSString*url=[NSString stringWithFormat:@"%@/WEB/mobile/help_list_app.aspx",BESTHOST];
    helpview.urlString=url;
    [self.navigationController pushViewController:helpview animated:YES];

}
//关于我们   签到送积分
-(void)aboutwe
{
    [Controller requestWithURL:PostSignIn jsondic:nil finishBlock:^(ClassData* data) {
        if ([data.number isEqualToNumber:[NSNumber numberWithInteger:0]])
        {
//            "USER_SCORE" = 220;
//            "USER_SCORE_INC_MSG" = "\U6bcf\U65e5\U7b7e\U5230\Uff0c\U606d\U559c\U60a8\U83b7\U5f975\U79ef\U5206\Uff01";
//            "USER_SCORE_INC_NUM" = 5;
            
            UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                message:data.data[@"USER_SCORE_INC_MSG"]
                                                               delegate:nil
                                                      cancelButtonTitle:@"确定"
                                                      otherButtonTitles:nil];
            [alertView show];
            
           
            NSString *jifen=[NSString stringWithFormat:@"%d",[data.data[@"USER_SCORE"] integerValue]];
            numberarray[1]=jifen;
            
            //刷新积分数据
            [self upguanliView];
            
        }
        else
        {
           ALERTSHOW(data.message);
            
        }
    }];
    

}
//意见反馈
-(void)yijianfankui
{
        //拨打电话
        //进入打电话页面
        UIWebView *webview = [[UIWebView alloc] init];
        [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel:4008850051"]]];
        [self.view addSubview:webview];

}

//呼叫客户
-(void)callout
{
    //进入打电话页面
    UIWebView *webview = [[UIWebView alloc] init];
    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"tel:4008850051"]]];
    [self.view addSubview:webview];
//    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"tel://4008850051"]];

}

@end
